package com.financing.platform.web;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.financing.platform.dto.AccountWithdrawDTO;
import com.financing.platform.service.IAccountWithdrawService;
import com.financing.platform.util.DTOdateSet;
import com.financing.platform.util.Dict;
import com.financing.platform.vo.AccountWithdrawVO;

/**
 * 
 * @ClassName: AccountWithdrawAction
 * @Description: 提现Action 
 * @author  lisu
 *
 */
@Controller
public class AccountWithdrawAction extends BaseAction{
	
	@Autowired
	private IAccountWithdrawService accountWithdrawServiceImpl;
	
	/**
	 * 
	 * @Title: queryAccountWithdraw
	 * @Description: 提现 
	 * @param @param request
	 * @param @param response
	 * @param @param AccountWithdrawVO
	 * @param @return   
	 * @return ModelAndView   
	 * @throws
	 */
	@RequestMapping("/queryAccountWithdraw.shtml")
	public ModelAndView queryBankCard(HttpServletRequest request,
			HttpServletResponse response,AccountWithdrawVO accountWithdrawVo,Map<String,Object> resultMode) {
		
		this.log.info("begin queryAccountWithdraw info!");
		
		request.getSession().setAttribute(Dict.requestID, "queryAccountWithdraw.shtml");
		
		try{
			
			//List<BankCardVO> bankCardVOs = bankCardServiceImpl.queryBankCardList(cardVO);
			
			List<AccountWithdrawVO> accountWithdrawVOs = accountWithdrawServiceImpl.queryAccountWithdrawList(accountWithdrawVo);
			
			resultMode.put("list", accountWithdrawVOs);
			resultMode.put("bean",accountWithdrawVo);
			
		}catch(Exception e){
			this.log.error("error queryAccountWithdraw",e);
		}
		this.log.info("end queryAccountWithdraw info access !");
		return new ModelAndView("accountWithdrawList", resultMode);
	}
	/**
	 * 
	 * @Title: queryAccountWithdrawDetail
	 * @Description: 提现 明细
	 * @param @param request
	 * @param @param response
	 * @param @param AccountWithdrawVO
	 * @param @return   
	 * @return ModelAndView   
	 * @throws
	 */
	@RequestMapping("/queryAccountWithdrawDetail.shtml")
	public ModelAndView queryAccountWithdrawDetail(HttpServletRequest request,
			HttpServletResponse response,Integer id) {
		
		this.log.info("begin queryAccountWithdrawDetail info!");
		
		request.getSession().setAttribute(Dict.requestID, "queryAccountWithdraw.shtml");
		
		Map<String,Object> resultMode = new HashMap<String,Object>();
		
		try{
			
			//List<BankCardVO> bankCardVOs = bankCardServiceImpl.queryBankCardList(cardVO);
			
			AccountWithdrawVO accountWithdrawVO = accountWithdrawServiceImpl.queryAccountWithdrawInfo(id);
			
			resultMode.put("bean",accountWithdrawVO);
			
		}catch(Exception e){
			this.log.error("error queryAccountWithdraw",e);
		}
		this.log.info("end queryAccountWithdraw info access !");
		return new ModelAndView("accountWithdrawDetail", resultMode);
	}
	/**
	 * 
	 * @Title: updateWithdrawStatus
	 * @Description: 提现-修改状态
	 * @param @param request
	 * @param @param response
	 * @param @param accountWithdrawDTO
	 * @param @return   
	 * @return ModelAndView   
	 * @throws
	 */
	@RequestMapping("/updateWithdrawStatus.shtml")
	public ModelAndView updateWithdrawStatus(HttpServletRequest request,
			HttpServletResponse response,AccountWithdrawDTO accountWithdrawDTO) {
		
		this.log.info("begin updateWithdrawStatus info!");
		
		Map<String,Object> resultMode = new HashMap<String,Object>();
		
		try{
			//赋值
			DTOdateSet.setUpdateInfo(accountWithdrawDTO, request.getSession());
			//提现-修改状态
			int updateCount = accountWithdrawServiceImpl.updateAccountWithdraw(accountWithdrawDTO);
			resultMode.put("result", updateCount);
			
		}catch(Exception e){
			this.log.error("error queryAccountWithdraw",e);
		}
		this.log.info("end queryAccountWithdraw info access !");
		return queryBankCard(request,response,null,resultMode);
	}
	
}
